package com.common.www.repository.tabulation;

import org.springframework.boot.base.jpa.repository.support.ExtendedRepository;
import com.common.www.bean.entity.tabulation.XfgcBidBaseTabulation;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Repository
public interface XfgcBidBaseTabulationRepository extends ExtendedRepository<XfgcBidBaseTabulation, Long> {

    /**
     * 按项目查询
     * @param flag
     * @param projectId
     * @return
     */
    List<XfgcBidBaseTabulation> findByFlagAndProjectId(Integer flag,Long projectId);


    /**
     * 按项目、标底类型、分类查询
     * @param flag
     * @param projectId
     * @param xiTongFenLei
     * @return
     */
    List<XfgcBidBaseTabulation> findByFlagAndProjectIdAndXiTongFenLei(Integer flag,Long projectId,String xiTongFenLei);

    /**
     * 查询标底清单的增补清单内容
     * @param projectId
     * @return
     */
    @Query(value = "SELECT * FROM xfgc_bid_base_tabulation WHERE flag = 1 AND project_id = :projectId AND name_type2 is not null ",nativeQuery = true)
    List<XfgcBidBaseTabulation> getZengBuList(@Param("projectId") Long projectId);

    /**
     * 按项目删除
     * @param projectId
     * @return
     */
    @Modifying
    @Transactional
    int deleteByProjectId(Long projectId);
}
